const mysql = require('mysql');
var connction = require('./connction'); //连接池
const pool = mysql.createPool(connction.mysql);


 //返回一个Promise链接
const connectHandle = () => new Promise((resolve, reject) => {
   pool.getConnection((err, connection) => {
     if(err) {
       console.error('链接错误：' + err.stack + '\n' + '链接ID：' + connection.threadId)
       reject(err)
     } else {
       resolve(connection)
     }
   })
 })
 

 
 module.exports = connectHandle;